/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package babydisco.Math.SVD;

import java.util.ArrayList;
import babydisco.Math.Jama.*;
import babydisco.Math.Spectogram;

/**
 * SVD that works, it uses the same algorithm
 * @author Florian
 */
public class SVD {
     private Spectogram Spec;
     private double sampleFreq;
     private ArrayList<Double> input;
     private Matrix s;
     private SingularValueDecomposition svd;
     public SVD(ArrayList<Double> input, double sampleFreq) {
        Spec = new Spectogram(input, sampleFreq);
        this.input = input;
        this.sampleFreq = sampleFreq;
        createS();
        svd = new SingularValueDecomposition(s);
    }
     private void createS() {
        int m = Spec.getSlices().size();
        int n = Spec.getSlices().get(0).getAmplitude().size();
        double [][] temp = new double[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                temp[i][j] = Spec.getSlices().get(i).getAmplitude().get(j);
            }
        }
        s = new Matrix(temp);
       
    }

    public Matrix getSingularMatrix(){return svd.getS();}
    public Matrix getV(){return svd.getV();}
    public Matrix getU(){return svd.getU();}
    public double getSampleFreq(){return sampleFreq;}


   
}
